package exercise;

public class Triangle extends Shape {
    protected double firstEdge ;
    protected double secondEdge ;
    protected double thirdEdge ;

    public Triangle(double firstEdge, double secondEdge , double thirdEdge){
        // 可以在这里完成对 type 的初始化
        this.firstEdge = firstEdge;
        this.secondEdge = secondEdge ;
        this.thirdEdge = thirdEdge ;
        type = "三角形" ;
    }
    public void calculate() {
        // 在这里计算三角形的面积，并将面积存储到 area 变量中 ( area 是从父类继承的、可见的实例变量 )
        double p = (this.firstEdge + this.secondEdge + this.thirdEdge)/2;
        this.area = Math.pow( p * ( (p - this.firstEdge) * (p - this.secondEdge) * (p - this.thirdEdge)) , 0.5);
    }

    public void description() {
        // 在这里输出三角形基本信息(比如三边的长度)
        // 最后通过调用从父类继承的、可见的 show 方法输出 三角形的面积
        System.out.println( "三角形三边长分别为：" + firstEdge + " ," + secondEdge + " " +secondEdge );
        this.show();
    }
}